const router = require('koa-router')()

router.get('/', async (ctx, next) => {
  // await ctx.render('index', {
  //   title: 'Hello Koa 2!'
  // })
  console.log(ctx.request.body, 12334141)
  ctx.body = {
    title: 'Hello Koa 2!'
  }
})

router.post('/', async (ctx, next) => {

  console.log(ctx.request.body, 12334141)
  ctx.body = {
    title: 'Hello Koa 2, post!'
  }
})

router.get('/string/:id', async (ctx, next) => {
  console.log(ctx.query, 'ctx.query')
  ctx.body = 'koa2 string' + ctx.params.id
})

router.get('/json', async (ctx, next) => {
  ctx.body = {
    title: 'koa2 json'
  }
})

module.exports = router
